package com.tencent.wxcloudrun.controller.zuke;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.pojo.dto.resp.CurHouseDetailResp;
import com.tencent.wxcloudrun.pojo.dto.resp.GetHomeListResp;
import com.tencent.wxcloudrun.service.business.zuke.CurHouseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 具体房屋信息页中的收藏与房东电话在别的控制层有现成的接口可以获取
 */
@RestController
@RequestMapping("/curHouse")
public class CurHouseController {

    @Resource
    private CurHouseService curHouseService;

    /**
     * 点击当前租房的tag标签后，调用此接口，先获取当前租客有几个正在租住的房子，以列表的形式进行展示
     * 借用了房东的房屋管理的房屋列表接口返回的对象进行返回
     */
    @GetMapping("/getHomeList")
    public ApiResponse<List<GetHomeListResp>> getHomeList() {
        return new ApiResponse<>(curHouseService.getHomeList());
    }

    /**
     * 点击其中一个房子后，调用此接口，获取对应的房子信息进行展示
     */
    @GetMapping("/getHouseInfo")
    public ApiResponse<CurHouseDetailResp> getHouseInfo(@RequestParam("houseId") String houseId) {
        return new ApiResponse<>(curHouseService.getHouseInfo(houseId));
    }

    /**
     * 发起退租申请
     */
    @GetMapping("/applyQuit")
    public ApiResponse<String> applyQuit(@RequestParam("houseId") String houseId) {
        return new ApiResponse<>(curHouseService.applyQuit(houseId));
    }
}
